<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class CreateUserRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            //
            'name' => 'required',
            'email' => 'required|email',
            'phone' => ['required', 'regex:/^(13|15|17|18)\d{9}$/'],
            'password' => 'required'
        ];
    }

    public function messages()
    {
        return [
            'name.required' => '必须填写用户名',
            'email.required' => '必须填写电子邮箱',
            'email.email' => '必须填写有效的电子邮箱',
            'password.required' => '必须填写密码',
            'phone.required' => '必须填写手机号',
            'phone.regex' => '必须填写有效的手机号',
        ];
    }
}
